<template>
  <div>
    <div v-if="!show" class="content">
      <el-row>
        <el-col :span="8" v-for="(carl,index) in cartoonList" :offset="index > 0 ? 2 : 0" class="car">
          <el-card :body-style="{ padding: '0px' }">
            <img :src="'http://api.ishuhui.com/'+carl.avatar" alt="" class="image">
            <div style="padding: 5px;">
              <router-link :to="'/details/'+carl.id">
                <span>{{carl.name}}</span>
                <br>
                <span>更新至{{carl.number}}话</span>
              </router-link>
              
              <div class="bottom clearfix">
                <span class="title">{{ carl.title }}</span>
                <el-button type="text" class="button" @click="clear(carl.book)">
                  取消订阅
                </el-button>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>





    </div>
  </div>
</template>
<script>

  export default {
    data() {
      return {
        show: true,
        user: {},
        bok:{
          book:"",
          type:1
        },
        cartoonList: [],
        animeList: []
      }
    },
    methods: {
      shows(val) {
        this.show = val
      },
      clear(val){
        this.bok.book = val 
        this.axios.post('http://u.ishuhui.com/rss/del',this.bok)
          .then(data=>{
            console.log(data)
          })
          .catch(err=>{
            console.log(err)
          })
      }
    },
    created() {
      this.user = localStorage.getItem('userrss')
      if (this.user) {
        this.show = false
        this.axios.get('http://api.ishuhui.com/index/rss/ver/49147755/rss/' + this.user + '.json')
          .then(data => {
            console.log(data.data.data.cartoon)
            this.cartoonList = data.data.data.cartoon
            this.animeList = data.data.data.anime
          })
          .catch(err => {
            console.log(err)
          })
      } else {
        this.show = true
        this.$message('您还未登录，请先登录')
        this.$router.push({path:'/users'})
      }
    }
  }

</script>
<style scoped>
  .content {
    padding: 0 15px;
  }
  
  .content li {
    overflow: hidden;
    margin: 10px 0;
  }
  
  .car {
    width: 2rem;
    text-align: center;
    overflow: hidden;
  }
  /*.content img {
    float: left;
    width: 1.5rem;
  }*/
  
  .title {
    display: block;
    
    font-size: 13px;
    color: #999;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  
  .bottom {
    margin-top: 13px;
    line-height: 12px;
  }
  
  .button {
    padding: 0;
    float: right;
    margin-top: 10px;
  }
  
  .image {
    width: 100%;
    display: block;
    
  }
  
  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  
  .clearfix:after {
    clear: both
  }

</style>
